package com.ruoyi.web.controller.bank;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bank.domain.BankDomicile;
import com.ruoyi.bank.service.IBankDomicileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评议情况Controller
 * 
 * @author ruoyi
 * @date 2024-03-15
 */
@RestController
@RequestMapping("/bank/domicile")
public class BankDomicileController extends BaseController
{
    @Autowired
    private IBankDomicileService bankDomicileService;

    /**
     * 查询评议情况列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BankDomicile bankDomicile)
    {
        startPage();
        List<BankDomicile> list = bankDomicileService.selectBankDomicileList(bankDomicile);
        return getDataTable(list);
    }

    /**
     * 导出评议情况列表
     */

    @Log(title = "评议情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankDomicile bankDomicile)
    {
        List<BankDomicile> list = bankDomicileService.selectBankDomicileList(bankDomicile);
        ExcelUtil<BankDomicile> util = new ExcelUtil<BankDomicile>(BankDomicile.class);
        util.exportExcel(response, list, "评议情况数据");
    }

    /**
     * 获取评议情况详细信息通过domicileId
     */

    @GetMapping(value = "/by-id/{domicileId}")
    public AjaxResult getInfoById(@PathVariable("domicileId") Long domicileId)
    {
        return success(bankDomicileService.selectBankDomicileByDomicileId(domicileId));
    }

    /**
     * 获取评议情况详细信息通过domicileNumber
     */
    @GetMapping(value = "/by-number/{domicileNumber}")
    public AjaxResult getInfoByNumber(@PathVariable("domicileNumber") String domicileNumber)
    {
        return success(bankDomicileService.selectBankDomicileByDomicileNumber(domicileNumber));
    }


    /**
     * 新增评议情况
     */

    @Log(title = "评议情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankDomicile bankDomicile)
    {
        return toAjax(bankDomicileService.insertBankDomicile(bankDomicile));
    }

    /**
     * 修改评议情况
     */

    @Log(title = "评议情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankDomicile bankDomicile)
    {
        return toAjax(bankDomicileService.updateBankDomicile(bankDomicile));
    }

    /**
     * 删除评议情况
     */

    @Log(title = "评议情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{domicileIds}")
    public AjaxResult remove(@PathVariable Long[] domicileIds)
    {
        return toAjax(bankDomicileService.deleteBankDomicileByDomicileIds(domicileIds));
    }
}
